import { createStore, combineReducers } from 'redux'
import { count } from './reducer/count'
import { num } from './reducer/num'

// react-redux


// 使用combineReducers进行模块拆分
// 使用combineReducers后可以把initState给省略点

let reducer = combineReducers({
    count,
    num
})

// redux模块拆分
// let reducer = (state, action) => {
//     return {
//         count: count(state.count, action),
//         num: num(state.num, action)
//     }
// }

// let reducer = (state, action) => {
//     let NewState = JSON.parse(JSON.stringify(state))
//     switch (action.type) {
//         case "COUNT_ADD":
//             NewState.count += 1
//             return NewState
//         case "NUM_ADD":
//             NewState.num += 1
//             return NewState
//         default:
//             return state
//     }
// }

// let initState = {
//     count: 100,
//     num: 888
// }

let store = createStore(reducer)

export default store